<?php
include dirname(__FILE__) . "/config/functions.php";
unset($_SESSION['advertiseImg']);
unset($_SESSION['advertiseTxt']);

$optionsQuery = mysql_query("SELECT * FROM `option`");
while($row = mysql_fetch_assoc($optionsQuery))    $options[$row['key']] = $row['value'];


$banner = mysql_query("SELECT * from `option` where `key` LIKE '%banner_price_%'");
$sponsor = mysql_query("SELECT * from `option` where `key` LIKE '%link_price_%'");

if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['impressions'])) {
    $error1 = '';
    if ($_POST['impUrl'] == 'http://') {
        $error1 .= 'Website Url Field can\'t be blank.<br>';
    } elseif (strlen($_POST['impUrl']) > 100) {
        $error1 .= 'Website Url Field can\'t exceed 100 charachters.<br>';
    }
    if ($_POST['bannerUrl'] == 'http://') {
        $error1 .= 'Banner Url Field can\'t be blank.<br>';
    } elseif (strlen($_POST['bannerUrl']) > 100) {
        $error1 .= 'Banner Url Field can\'t exceed 100 charachters.<br>';
    }
    if (!$error1) {
        $_SESSION['advertiseImg'] = $_POST;
        header('location: advertise2.php');
    }
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['hits'])) {
    $error2 = '';
    if ($_POST['hitUrl'] == 'http://') {
        $error2 .= 'Website Url Field can\'t be blank.<br>';
    } elseif (strlen($_POST['hitUrl']) > 100) {
        $error2 .= 'Website Url Field can\'t exceed 100 charachters.<br>';
    }
    if ($_POST['textAd'] == '') {
        $error2 .= 'Ad Text Field can\'t be blank.<br>';
    } elseif (strlen($_POST['textAd']) > 150) {
        $error2 .= 'Ad Text Field can\'t exceed 150 charachters.<br>';
    }
    if (!$error2) {
        $_SESSION['advertiseTxt'] = $_POST;
        header('location: advertise2.php');
    }
}
?>
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!-- Consider adding a manifest.appcache: h5bp.com/d/Offline -->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title><?= $options['site_name'] ?></title>
        <meta property="og:title" content="<?= $options['site_name'] ?>">
        <meta property="og:site_name" content="<?= $options['site_name'] ?>">
        <meta property="og:type" content="<?= $options['type'] ?>">
        <meta property="og:url" content="<?= $options['url'] ?>">
        <meta property="og:image" content="<?= $options['image'] ?>">
        <meta property="fb:admins" content="<?= $options['admins'] ?>">
        <meta name="description" content="<?= $options['site_description'] ?>">
        <meta name="keywords" content="<?= $options['keywords'] ?>">
        <meta name="author" content="<?= $options['author'] ?>">
        <meta name="Robots" content="<?= $options['Robots'] ?>">
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
        <link href="css/bootstrap.min.css" rel="stylesheet"/>
        <link href="css/style.css" rel="stylesheet"/>
    </head>
    <body>
        <!-- Save for Web Slices (index.psd) -->
        <table width="950" height="1" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
            <tr>
                <td background="images/bg.png">
                    <img src="images/header.png" alt="Viral Marketing Script - Your MEGA Traffic on Over-Drive!" width="950" height="294" lowsrc="Viral Marketing Script - Your MEGA Traffic on Over-Drive!"></td>
            </tr>
            <tr>
                <td background="images/bg.png"><div align="center"><strong><span class="style4">
                                :: <a href="index.php">Home</a> 
                                :: <a href="contact.php">Contact Us</a> 
                                :: <a href="advertise.php">Advertise</a> 
                                :: <a href="member/login.php">Login</a> 
                                ::</span></strong></div>
                </td>
            </tr>
            <tr>
                <td background="images/bg.png">
                    <div align="center">
                        <div class="container"> 
                            <div style="margin: 7px;"> 
                                <?php $_position = 'top'; ?>
                                <?php include dirname(__FILE__) . '/_banner.php'; ?>
                            </div>
                            <div class="row">
                                <div class="main text-center text-page"> 
                                    <h2><b>Advertise on Viral Marketing.</b></h2>
                                    <div class="text-page-left">
                                        <p><b>Viral Marketing Advertising Options </b>Promote your web site here at Viral Marketing. With Viral Marketing, there are 2 different ways that you can promote your product or web site. We have options that cater to a variety of advertising needs as well as different budget-types. These options give you the opportunity to take advantage of the large number of users and the visitors that use the site daily.</p>
                                        <p>1) <b>Banner Advertisement:</b> <br>
                                            <?php while ($row = mysql_fetch_array($banner)) : ?>
                                                <?php $value = explode("^", $row['value']); ?>
                                                $<?= number_format($value[1], 2) ?> per <?= number_format($value[0]) ?> Banner Impressions rotated at each page.<br>
                                            <?php endwhile; ?>
                                    </div>



                                    <p style="color: #FF7C01;font-weight: bold;font-size: 20px"><b>For Banner Advertisement !!</b></p>
                                    <?php if (isset($error1)): ?>
                                        <div class="alert alert-danger" style="margin: 0 auto 20px;width: 50%;">
                                            <?= $error1; ?>
                                        </div>
                                    <?php endif; ?> 
                                    <form action="" method="post" class="form-horizontal signupForm" role="form">
                                        <div class="form-group">
                                            <label for="bannerUrl" class="col-sm-3 control-label">Banner URL</label>
                                            <div class="col-sm-6">
                                                <input required='required'type="text" class="form-control" name="bannerUrl" size="25" value="<?= (isset($_POST['bannerUrl'])) ? $_POST['bannerUrl'] : 'http://'; ?>">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="url" class="col-sm-3 control-label">Website URL</label>
                                            <div class="col-sm-6">
                                                <input required='required'type="text" class="form-control" name="impUrl" size="25" value="<?= (isset($_POST['impUurl'])) ? $_POST['impUrl'] : 'http://'; ?>">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="credits" class="col-sm-3 control-label">Impressions</label>
                                            <div class="col-sm-6" class="form-control">
                                                <select name="credits" class="form-control">
                                                    <?php
                                                    $query = "SELECT * from `option` where `key` LIKE '%banner_price_%'";
                                                    $adBanners = mysql_query($query);

                                                    while ($row = mysql_fetch_array($adBanners)) :
                                                        ?>
                                                        <?php $value = explode("^", $row['value']);
                                                        echo $value[0];
                                                        ?>
                                                        <option value="<?php echo $row['value']; ?>"><?php echo $value[0]; ?> impressions - cost $<?php echo $value[1]; ?></option>
<?php endwhile; ?>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <div style="width: 136.333%;">
                                                <button type="submit" class="btn btn-default" name="impressions">Preview</button>
                                            </div>
                                        </div>
                                    </form>

                                    <img src="images/lineDivider.png" >

                                    <div class="text-page-left">
                                        <p>2) <b>Sponsor Ads Advertisement:</b> <br>
                                            <?php while ($row = mysql_fetch_array($sponsor)) : ?>
                                                <?php $value = explode("^", $row['value']); ?>
                                                $<?= number_format($value[1], 2) ?> per <?= number_format($value[0]) ?> Sponsor Ad Hits , your ad will be displayed in the sponsor ads section.   <br>  
<?php endwhile; ?>
                                        </p> 
                                    </div>



                                    <p style="color: #FF7C01;font-weight: bold;font-size: 20px"><b>For Sponsor Ads Advertisement !!</b></p>
                                        <?php if (isset($error2)): ?>
                                        <div class="alert alert-danger" style="margin: 0 auto 20px;width: 50%;">
                                        <?= $error2; ?>
                                        </div>
<?php endif; ?> 
                                    <form action="" method="post" class="form-horizontal signupForm" role="form" >
                                        <div class="form-group">
                                            <label for="textAd" class="col-sm-3 control-label">Text Ad</label>
                                            <div class="col-sm-6">
                                                <input required='required'type="text" class="form-control" name="textAd" size="25" value="<?= (isset($_POST['textAd'])) ? $_POST['textAd'] : ''; ?>">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="webUrl" class="col-sm-3 control-label">Website URL</label>
                                            <div class="col-sm-6">
                                                <input required='required'type="text" class="form-control" name="hitUrl" size="25" value="<?= (isset($_POST['hitUrl'])) ? $_POST['hitUrl'] : 'http://'; ?>">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="textAd" class="col-sm-3 control-label">Hits</label>
                                            <div class="col-sm-6">

                                                <select name="credits" class="form-control">
                                                    <?php
                                                    $query = "SELECT * from `option` where `key` LIKE '%link_price_%'";
                                                    $adLinks = mysql_query($query);

                                                    while ($row = mysql_fetch_array($adLinks)) :
                                                        ?>
                                                        <?php $value = explode("^", $row['value']);
                                                        echo $value[0];
                                                        ?>
                                                        <option value="<?php echo $row['value']; ?>"><?php echo $value[0]; ?> hits - cost $<?php echo $value[1]; ?></option>
<?php endwhile; ?>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <div style="width: 136.333%;">
                                                <button type="submit" class="btn btn-default" name="hits">Preview</button>
                                            </div>
                                        </div>
                                    </form>

                                </div> 


                            </div> 
                            <div style="margin: 25px 25px -25px;"> 
<?php $_position = 'bottom'; ?>
<?php include dirname(__FILE__) . '/_banner.php'; ?>
                            </div>
                        </div>
                        <BR><BR>
                    </div>
                </td>
            </tr>
            <tr>
                <td background="images/bg.png"><div align="center">
<?php include dirname(__FILE__) . '/footer.php'; ?>
                    </div></td>
            </tr>
            <tr>
                <td>
                    <img src="images/footer.png" width="950" height="108" alt=""></td>
            </tr>
        </table>
        <script src="js/jquery-1.10.2.min.js"></script>
        <script src="js/bootstrap.min.js"></script>

        <!-- End Save for Web Slices -->
    </body>
</html>    
